
import javax.swing.JApplet;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Menu.java
 *
 * Created on Oct 15, 2011, 6:25:09 PM
 */
/**
 *
 * @author Riso-Desktop
 */
public class Menu extends JApplet implements Runnable {

    Thread nacitajskore = new Thread(this);
    Highscore hscore = new Highscore();
    Okno okno = new Okno();

    @Override
    public void init() {
        this.setSize(960, 600);
        initComponents();
    }

    /** Creates new form Menu */
    public Menu() {
        nacitajskore.start();
        okno.setBounds(0, 0, 960, 600);
        hscore.setBounds(0, 0, 960, 600);
        this.add(okno);
        this.add(hscore);
        hscore.setVisible(false);
        okno.setVisible(false);
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();

        getContentPane().setLayout(null);

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/high_nestlac.png"))); // NOI18N
        jButton1.setBorderPainted(false);
        jButton1.setContentAreaFilled(false);
        jButton1.setFocusPainted(false);
        jButton1.setMargin(null);
        jButton1.setMaximumSize(new java.awt.Dimension(133, 52));
        jButton1.setMinimumSize(new java.awt.Dimension(133, 52));
        jButton1.setPreferredSize(new java.awt.Dimension(133, 52));
        jButton1.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/img/high_stlac.png"))); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton1);
        jButton1.setBounds(10, 450, 133, 52);

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/start_nestlac.png"))); // NOI18N
        jButton2.setBorderPainted(false);
        jButton2.setContentAreaFilled(false);
        jButton2.setFocusPainted(false);
        jButton2.setMargin(null);
        jButton2.setMaximumSize(new java.awt.Dimension(133, 52));
        jButton2.setMinimumSize(new java.awt.Dimension(133, 52));
        jButton2.setPreferredSize(new java.awt.Dimension(133, 52));
        jButton2.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/img/start_stlac.png"))); // NOI18N
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton2);
        jButton2.setBounds(10, 390, 133, 52);

        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/exit_nestlac.png"))); // NOI18N
        jButton3.setBorderPainted(false);
        jButton3.setContentAreaFilled(false);
        jButton3.setFocusPainted(false);
        jButton3.setMargin(null);
        jButton3.setMaximumSize(new java.awt.Dimension(133, 52));
        jButton3.setMinimumSize(new java.awt.Dimension(133, 52));
        jButton3.setPreferredSize(new java.awt.Dimension(133, 52));
        jButton3.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/img/exit_stlac.png"))); // NOI18N
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton3);
        jButton3.setBounds(10, 510, 133, 52);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/back.png"))); // NOI18N
        getContentPane().add(jLabel1);
        jLabel1.setBounds(0, 0, 960, 600);
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        hscore.setVisible(true);
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:
        System.exit(0);
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        hscore.setVisible(true);
        okno.novahra();
        okno.setVisible(true);
        okno.hra.setVisible(true);
        okno.hra.hrabezi = true;
        jButton2.setSelected(false);
    }//GEN-LAST:event_jButton2ActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    // End of variables declaration//GEN-END:variables

    @Override
    public void run() {
        
        while(nacitajskore!=null){
            if(okno.hrabezi==false){
                hscore.nacitajskore();
            }
            try {
                nacitajskore.sleep(50);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
